package learn_concurrent._8;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class T2 {
	static final Logger logger = LoggerFactory.getLogger(T2.class);

	static final Object lock = new Object();
	static boolean t2IsRun = false;
	public static void main(String[] args) throws InterruptedException {
		
		new Thread(() -> {
			synchronized(lock) {
				while(!t2IsRun) {
					logger.info("^^^");
					try {
						lock.wait();
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					logger.info(">>>");
				}
				logger.info("1");
			}
		}, "t1").start();
		
		new Thread(() -> {
			synchronized(lock) {
				logger.info("2");
				t2IsRun = true;
				lock.notify();
			}
		}, "t2").start();
		
	}

}
